package com.qf.controller;

import com.qf.entity.Goods;
import com.qf.service.SearchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/searchController")
public class SearchController {

    @Autowired
    private SearchServiceImpl searchService;

    @RequestMapping("/searchGoods")
    public String searchGoods(String keyword, @RequestParam(name = "orderBy", defaultValue = "1") Integer orderBy, ModelMap modelMap) throws Exception {
        // 1.从es查询数据
        List<Goods> goodsList = searchService.searchGoodsList(keyword, orderBy);
        modelMap.put("goodsList", goodsList);
        return "searchList";
    }
}
